import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:tp_upgrade_lib/tp_update_widget.dart';
import 'package:tp_upgrade_lib/tp_upgrade_lib.dart';

import 'tp_update_util.dart';

void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  runApp( MyApp());
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.blue,
        title: const Text('Plugin example app'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          MaterialButton(onPressed: ()=>onDownTap(context),child: Text('点击更新'),color: Colors.blue,)
          // SizedBox(
          //   height: 30,
          //   width: 30,
          //   child: CircularProgressIndicator(
          //     // value: null,
          //     // backgroundColor: backgroundColor,
          //     valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
          //   ),
          // )
        ],
      ),
    );
  }

  onDownTap(BuildContext context) {
    TpUpdateUtil.checkVs(context);
  }

}
